Hacking with GeoScript

The 3.0 release of the OpenGeo Suite added a variety of software features and improvements, including spatial processing capabilities. With scripting support, languages like JavaScript and Python could be leveraged to fit your needs. These scripting languages expose the GeoScript library, allowing users to leverage all GeoScript functions in processing scripts. While OpenGeo Suite 3.0 ships with many useful processes, the additional server-side scripting allows you to deploy many more to fit your enterprise’s specific wants and needs.

You may be surprised to hear that the GeoScript project is nearly 3 years old. In this time it’s accumulated a good deal of functionality. I find myself using the library daily to perform a variety of tasks and I thought sharing some of the most common things I do with GeoScript might be helpful to you.

Data Conversion

Recently I worked on a project that involved analyzing and improving GeoServer rendering performance with Oracle. The first step was to gather a baseline measurement of “acceptable performance”. In order to measure respective rendering time between the two databases with the same data our plan was to port all the data to PostGIS. As requested the client sent a dump of their Oracle database and we got to work on converting it:

Voila! After some GeoScript magic we had a PostGIS database with all the client data.

Styling

One of the most common uses I find for GeoScript is to quickly prototype and create styles. Users of GeoServer know the pain of authoring styles directly in SLD; even with visual tools common tasks like creating “road casings” are often tedious. Here’s an example of some OSM styling that GeoScript made easy.

I’ve been load-testing GeoServer quite a bit lately and do so I have to generate test plans that execute a number of WMS requests. In this case I wanted the tests to simulate a typical scenario of concentrated access centering on major cities.

Last we generate bounding box tiles that intersect the city limits for the zoom levels I want available:

# go from min to max zooms
for z in range(8, 15):
# get resolution of this zoom level
res = 1.0/pow(2,z)
# tile our main bbox at this resolution within the city bounds
for t in box.tiles(r, city_bnds):
print '%f,%f,%f,%fn' % (t.west, t.south, t.east, t.north)

What’s Next?

The next big thing on the GeoScript roadmap is raster data support. It’s something I’m particularly excited about and happy to say that some of us at OpenGeo have been busy working on. Here is a quick sample of what’s to come:

And there you have it, raster analysis made easy with GeoScript. Remember that these are just a few examples of what’s possible with server-side scripting. Download the OpenGeo Suite and try it out for yourselves. We love feedback so if you have any questions or comments about GeoScript, or wrote something that you want to share please let us know. Leave a comment on this post or send us an email. Thanks for reading and happy scripting.