2

I'm trying to generate Zonal Statistics with a raster and set of polygons.

In my case the polygons represent census tracts in the US and the raster is population density.

The problem is that sometimes the raster and polygon don't overlap, because the raster only includes the lower 48 states, and I'm writing a script to loop over files from all states to do this operation, and those files include some Alaska/Hawaii files.

Is there a function to check if a raster and a polygon overlap?

Right now I'm working on ArcMap and just copying as snippet as I go:

enter image description here

This gives an error, because state number 02 is Alaska. Ideally it would be smart enough to skip this case.

  • 1
    Perhaps use extent.polygon and intersects for geometry. – FelixIP Nov 16 '19 at 2:41
0

You can determine if two layers overlap using the Intersect tool. Part of the standard toolbox in ArcGIS

| improve this answer | |
  • That tool doesn't seem to work for rasters... Only polygons. Plus, it creates a feature, while all I need is a True or False result. – Leo Barlach Nov 16 '19 at 2:28
  • The raster overlay tool might work but it again delivers a dataset. You should be able to use ArcPY to get what you want. What is the specific error that you are getting from zonal statistics? It's seems like it shouldn't error out but just deliver zero if the layers don't coincide. – jport Nov 16 '19 at 13:11
  • It's not a very useful error: ExecuteError: ERROR 999999: Error executing function. Failed to execute (ZonalStatisticsAsTable). – Leo Barlach Nov 18 '19 at 23:49
  • Are you getting any results? If not then are you sure both layers are in the same projection? – jport Nov 19 '19 at 0:35
  • no results. They are in the same projection (projected before). The issue is that no part of the polygon overlaps the raster. This is fine doing manually, but I wanted a way to loop over a bunch of polygon files and check for overlap before trying this. Right now I'm just manually hard-coding the states that don't overlap. – Leo Barlach Nov 20 '19 at 0:20

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.