Skip to main content

Posts

OGR2OGR tips

OGR2OGR is my primary tool for loading spatial data to PostGIS databases. It's useful because it can process many data formats and has enough functionality and speed to get the job done. It's command line. Some people love command line, but I'm not really a fan of committing syntax to memory, so here are some useful flags and options for OGR2OGR tasks. The basic command to load a shapefile looks like this: ogr2ogr -f "PostgreSQL" PG:"dbname='databasename' host=' addr ' port=' 5432 ' user=' x ' password=' y '" shapefile_name.shp This will load a shapefile to the default schema on the database. You can add options to the command for additional functionality. It's usually not important what order you put the options in the command, but the option's values go after the option. If there are spaces in the filename, you need to put double quotes around the filename and extension.   Progress -progress Th...
Recent posts

ArcMap raster calculator conditional statements

The Raster Calculator can do a lot, but the documentation is pretty scarce. I got stuck adding together multiple raster layers with null values in ArcMap. If one of the rasters has a cell with a null value, then when that cell is added to values from other cells it still equals null.   null + any value = null The way around this is to use a conditional statement.   Con( condition, value if true, value if false ) For example, to check if a cell value is null and reassign that cell value to zero if it is null:   Con(isNull("raster_layer"), 0, "raster_layer") So, if you want to sum two raster layers with null values and want to substitute zeros for the nulls, do this:   Con(IsNull("raster_layer_1"), 0, "raster_layer_1") +   Con(IsNull("raster_layer_2"), 0, "raster_layer_2") This works for ArcGIS Desktop 10.5 and you probably need the Spatial Analyst extension to be able to use the Raster Calculator. You could just us...