I'm new to GIS and was making some progress until getting rather stumped on this one. I've imported what I believe to be lat/lon data based on US FIPS county codes in weather alerts (NOAA SPC). When I use the geodjango "simplify" method on my geometries, they render on a map according to my expectations. But when I attempt to perform relationship queries on the raw geometries, I get distance and overlap values that do not correspond to the real world geography. For example, the two upper blobs in this top image should be adjacent and much further south, and the lower blob should fit Florida better (the distances and overlaps in this image match my ST_Distance and ST_Overlaps values):

Distorted geometry

Here is a rendering of the "simplify" geometry, which shows how these spatial entities are truly related in the real world (pink regions):

Correct geometry

Does this distortion look familiar to anyone? Thanks!!

  • Include more info on what you're downloading and/or some raw coordinates? I just poked around the Storm Prediction Center and couldn't decide what data you were using. – mkennedy Jun 21 '13 at 21:51
  • Hi @mkennedy -- thanks for checking that out! And thanks for helping me make my question clearer. Saw your comment a few hours ago and it set a lot of useful debugging into motion; the downside is right now my assumptions are shaken to where updating the question doesn't make sense. I'll follow up here with either a revised question or a report. But just to not leave you hanging, here's an SPC product with the FIPS codes I mentioned: spc.noaa.gov/products/watch/wou0100.html Again, big thanks for asking just the right question :) – mph Jun 22 '13 at 5:07
  • If this: "LAT...LON 36598127 35028280 35028581 36598434" lat1: 36 deg 59 min; lon1: -81 deg 27 min; etc. which they discuss elsewhere as a parallelogram, and then intersect it with a counties layer...I think! – mkennedy Jun 22 '13 at 7:14
  • That is slick! And I guess that's why they included that parallelogram ;) This db I'm working with has a fips field on the counties, but doing it this way could be a nice optimization (skip a bunch of python code). Right now my original problem looks like it stems from some other python code in the library I'm building against. Still no explanation for how those weird distortions occurred. Will post back here, hopefully within a few hours... – mph Jun 22 '13 at 22:24

So, it turns out the problem began in my usage of this old version of geodjango (django version 1.0, not sure which version of geodjango but it's old). The unionagg() method gave odd results (perhaps due to user error), which subsequent operations compounded into those strange geometries. By doing the aggregate union in raw sql, I was able to get the expected results.

Thanks again, @mkennedy.

If anyone has any suggestions for how to make this question and answer somehow useful to the community, let me know.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.