Thursday, August 22, 2013

Creating a SQlite database via 10.2 ArcPy

At ArcGIS 10.2, there is not support for SQLite database, according to Wikipedia is described as follows:

is a relational database management system contained in a small (~350 KB) C programming library. In contrast to other database management systems, SQLite is not a separate process that is accessed from the client application, but an integral part of it.
To create a SQLite database, use the CreateSQLiteDatabase().
 
import arcpy
# Set local variables
sqlite_database_path = 'C:/Data/Counties.sqlite'
# Execute CreateSQLiteDatabase
arcpy.gp.CreateSQLiteDatabase(sqlite_database_path, "ST_GEOMETRY")

It's not too hard.  All file paths must end in '.sqlite' extension.  The database supports two spatial types: "ST_GEOMETRY" or "SPATIALITE".  ST_GEOMETRY is Esri's storage type, whereas SPATIALITE is the SpatiaLite geometry type.  ST_GEOMETRY is the default geometry storage type.

This database can be fully used with the python sqlite3 module that comes as a default with any python installation.  This means you can create a database using ArcPy, then perform all updates through native SQL instead of update/insert cursors.

Some notes:

  • ":memory:" stored databases are not supported, they must be written to disk
  • SQLite version 3.16.2


Enjoy

Tuesday, August 6, 2013

Hurricane RSS Feeds

The National Hurricane Center has created two very helpful feeds for those who want to know the latest GIS hurricane data:

  • Atlantic Feed: http://www.nhc.noaa.gov/gis-at.xml
  • Pacific Feed: http://www.nhc.noaa.gov/gis-ep.xml
Each feed contains a wealth of information that can be parsed out:

  • Graphical Tropical Weather Outlook [shp]
  • 120h Wind Speed Probabilities (34kt, 50kt, 64kt) [shp] [kml]
  • Advisory Summary Information [xml]
  • Advisory Forecast Track [shp] [kml]
  • Advisory Cone of Uncertainty [shp] [kml]
  • Advisory Watches & Warnings [shp] [kml]
  • Advisory Wind Field [shp]
  • Preliminary Best Track [shp] [kml] & Wind Swath [shp]
  • Storm Surge (Probabilities, Exceedance) [shp] [kml]
shp means shapefile (in zip files) and kml is keyhole markup language (google format). 

This is a great improvement over the old way of trying to automate pulling data from the National Hurricane Center's website.  Hopefully next year they will improve these feeds by offering JSON or GeoJSON formats like the USGS has for new real time Earthquake data.