Tuesday, July 30, 2013
csv2gft
I've posted a public branch of code from the Lima Bean project to github as csv2gft. This might be very useful for someone who is doing daily pushes of new records to a Google Fusion Table from a csv dump.
Wednesday, May 8, 2013
Render Priority and KML from PHP/Postgres in one example
Working from a Google example I wrote some PHP that outputs KML from Postgres data, using region and lod to provide 'render priority' feel, based on a DB field. Here you go: https://github.com/bmearns/kml-priority
Wednesday, April 24, 2013
Sublayers with ArcGIS Online webmap and Javascript API
ArcGIS Online (ArcGIS.com) does a nice job of providing front ends for your web mapping services (particularly of the ArcGIS Server variety). In fact, ArcGIS Server 10.1 no longer comes with out of the box web mapping applications, relying instead on deployment through ArcGIS.com. ArcGIS.com provides a couple templates, for different use cases, that you can download and modify (though the performance hit of having the ArcGIS.com middleman is a concern).
One of the stumbling blocks I've identified in this new model is that ArcGIS.com -- and by extension ArcGIS Server -- does not provide any templates to allow the end user to control sublayer visibility. Thus, in migrating from ArcGIS Server pre-10.1 you may find that the sublayer control that was previously available by default through the out-of-the-box .NET (Java?) web applications is missing ... halting your entire migration.
After contacting Esri, I found it was necessary to code a custom solution.
Here is a modified Basic Viewer ArcGIS.com web template, which supports sublayers, through the layers checkbox widget (dojo dijit): http://www.udel.edu/001761
You'll need to add your ArcGIS.com webmap ID to that code, for it to function.
Or if you'd like to patch it yourself, apply this patch to /javascript/layout.js: http://www.udel.edu/001762
Note that this code will probably break if your map contains multiple map services with sublayers.
One of the stumbling blocks I've identified in this new model is that ArcGIS.com -- and by extension ArcGIS Server -- does not provide any templates to allow the end user to control sublayer visibility. Thus, in migrating from ArcGIS Server pre-10.1 you may find that the sublayer control that was previously available by default through the out-of-the-box .NET (Java?) web applications is missing ... halting your entire migration.
After contacting Esri, I found it was necessary to code a custom solution.
Here is a modified Basic Viewer ArcGIS.com web template, which supports sublayers, through the layers checkbox widget (dojo dijit): http://www.udel.edu/001761
You'll need to add your ArcGIS.com webmap ID to that code, for it to function.
Or if you'd like to patch it yourself, apply this patch to /javascript/layout.js: http://www.udel.edu/001762
Note that this code will probably break if your map contains multiple map services with sublayers.
Thursday, April 11, 2013
Running GDAL and arcpy together (ArcGIS 10.1, GDAL 1.9.2, python 2.7.4)
There are many use cases for running GDAL and arcpy in the same python instance. GDAL is the most popular open source geopspatial geoprocessing toolset and arcpy is Esri's python wrapper for the entire ArcGIS geoprocessing toolset.
However, doing so can get quite tricky. GDAL's python bindings are not easily configured for Windows (and ArcGIS/ArcObjects is Windows-only). The OSGeo4W project can be used to do so, but the bundled Python does not play well with arcpy. arcpy itself depends on numpy and requires multiple path inclusions.
Here are steps I took to import gdal and arcpy.
I tested by successfully running arcpy.RasterToNetCDF_md() (though I haven't tested gdal yet).
Step 1: Install standalone python to C:\Python274 (download from http://www.python.org/ftp/ python/2.7.4/python-2.7.4.msi)
Step 2: Add numpy (version bundled with ArcGIS) and Desktop10.1.pth to C:\Python274\Lib\site-packages (download from http://www.udel.edu/001745)
Step 3: Install GDAL binaries and python bindings (download installer from http://www.udel.edu/001742).
Step 4: Run import commands "import arcpy" and "from osgeo import gdal"
Some considerations:
arcpy is 32-bit (since it wraps arcobjects), so 32-bit python (etc.) are necessary
all versions of wrappers must be compatible with the same Python interpreter
However, doing so can get quite tricky. GDAL's python bindings are not easily configured for Windows (and ArcGIS/ArcObjects is Windows-only). The OSGeo4W project can be used to do so, but the bundled Python does not play well with arcpy. arcpy itself depends on numpy and requires multiple path inclusions.
Here are steps I took to import gdal and arcpy.
I tested by successfully running arcpy.RasterToNetCDF_md() (though I haven't tested gdal yet).
Step 1: Install standalone python to C:\Python274 (download from http://www.python.org/ftp/
Step 2: Add numpy (version bundled with ArcGIS) and Desktop10.1.pth to C:\Python274\Lib\site-packages (download from http://www.udel.edu/001745)
Step 3: Install GDAL binaries and python bindings (download installer from http://www.udel.edu/001742).
Step 4: Run import commands "import arcpy" and "from osgeo import gdal"
Some considerations:
arcpy is 32-bit (since it wraps arcobjects), so 32-bit python (etc.) are necessary
all versions of wrappers must be compatible with the same Python interpreter
Tuesday, December 11, 2012
Debugging maptiler on Mac
Running maptiler on Mac is no easy task, as I've found out.
While there are a few stumbling blocks when it comes to dependencies, one that I found particularly perplexing is the bundling of a two Python executables in the .app package. The maptiler executable is written in such a way as to not only to run the rest of the package through one or other of the Python executables, but to choose based on 32 or 64 bit architecture. That's independent of the version of Mac OS being run, or the "current" Python. Most dependency installers will install relative to the "current" Python, and its path. Therefore, on the 32-bit MacBook Pro I was testing on, I was being kicked on to the bundled Python 2.5 executable, and missing all my dependencies. This caused various dependency errors, including "ImportError: No module named osgeo"
While there are a few stumbling blocks when it comes to dependencies, one that I found particularly perplexing is the bundling of a two Python executables in the .app package. The maptiler executable is written in such a way as to not only to run the rest of the package through one or other of the Python executables, but to choose based on 32 or 64 bit architecture. That's independent of the version of Mac OS being run, or the "current" Python. Most dependency installers will install relative to the "current" Python, and its path. Therefore, on the 32-bit MacBook Pro I was testing on, I was being kicked on to the bundled Python 2.5 executable, and missing all my dependencies. This caused various dependency errors, including "ImportError: No module named osgeo"
Here is are the important diffs in maptiler.app that caused it to work:
in ../MapTiler.app/Contents/MacOS/maptiler
6,9c6,9
< #if sys.maxint > 2**32:
< executable = os.path.join(execdir, "PythonSnow")
< #else:
< # executable = os.path.join(execdir, "Python")
---
> if sys.maxint > 2**32:
> executable = os.path.join(execdir, "PythonSnow")
> else:
> executable = os.path.join(execdir, "Python")
and in ../MapTiler.app/Contents/Resources/maptiler/pp/__init__.py
141,147d140
< # fix PYTHONEXECUTABLE dict error
<
< if "PYTHONEXECUTABLE" in os.environ:
< executable = os.environ["PYTHONEXECUTABLE"]
< else:
< executable = sys.executable
<
156c149
< command = "\"" + executable + "\" -u \"" \
---
> command = "\"" + os.environ["PYTHONEXECUTABLE"] + "\" -u \"" \
Relevant link at Google Code: http://code.google.com/p/maptiler/issues/detail?id=42
Friday, December 7, 2012
My Places Overlays on Maptiler Google Map
Maptiler is a good option for creating image overlays (such as historical maps) on Google Maps. There are some snags though -- the code is still using gmaps API v2, which will give some indication for the attention being given to the project right now.
The problem I ran into was adding overlays (such as a KML or GeoRSS feed) on TOP of the image overlay, and correct behavior with the opacity slider built into the maptiler output.
Here are the simple edits to fix this issue.
The problem I ran into was adding overlays (such as a KML or GeoRSS feed) on TOP of the image overlay, and correct behavior with the opacity slider built into the maptiler output.
Here are the simple edits to fix this issue.
- Added a My Places KML overlay by copying the KML URL from My Places and these two lines (I put those at 185, just below the construction of the new map object)
- Changed zPriority of maptiler overlay so that it sits below other overlays (I edited the line at ~224 which constructs the "overlay" object
overlay = new GTileLayerOverlay( tilelayer,{zPriority:-1000}); - Finally, I fix the opacity slider by changing the line that removes all overlays to just remove the maptiler overlay, and reinitilize it at zPriority -1000 around line 62
this.map.removeOverlay(this.overlay); this.map.addOverlay(this.overlay, { zPriority: -1000 });
geoXml = new GGeoXml("https://maps.google.com/maps/ms?authuser=0&vps=1&ie=UTF8&msa=0&output=kml&msid=204904299571298064529.0004d01c986fdc0fe9f19");
map.addOverlay(geoXml);
- That's it!
Labels:
google maps,
historical map,
kml,
maptiler,
overlays
Hit the geocoding wall?
Google's Geocoding API limits results to 2,500/day. So what are your options when you hit a geocoding wall with a public/free API?
- Using ArcGIS (or alternatively Gisgraphy, which I have not yet experimented wtih http://www.gisgraphy.com/) you can geocode against the best data you can get your hands on. Esri Streetmaps Data is great, if you have access (as we do at UD). Or you could download public data, like the Census TIGER data, geonames, or an openstreetmap extract for the area you're interested in, and geocode on these. There is some high quality dataset from cities and states. In the case of Delaware, which licenses TeleAtlas (now TomTom) data, I don't think non-state users are permitted to use it. I have not seen a way to do this in open source GIS software (e.g., QGIS), which is why ArcGIS or Gisgraphy would be required
- Mapquest/Nomatim (http://developer.mapquest.
com/web/products/open/ nominatim) and Cloudmade have an unlimited geocoding APIs on OpenStreetMap data. Sometimes that can be slow or inaccurate though. - Mapquest (non-Nomatim) and Yahoo also have a 5000 result/day limit ... a 2x improvement on Google
Subscribe to:
Posts (Atom)