Select to view content in your preferred language

Find the location of a polygon in a big shapefile

2478
6
Jump to solution
11-14-2020 05:47 PM
ExGeoTique
Emerging Contributor

Hi everyone,

This is the first time I'm asking a question through the ESRI Community. Hopefully, I'll be able to find a solution to my small "project". I'll try to be as clear as possible.

Main idea: Let's say I have a big shapefile with properties boundaries. In another shapefile, I have only a few properties in a certain area. I'd like to analyze the first shapefile and find the location of the properties from the second file.

In other words, I have a big file with multiple different shapes sticked together. Is there a way to find where the shapes composed of a square and a triangle  ?

 

While the first file is georeferenced in a certain projection, the second file is not. The coordinates are wrong. This is why I'd like to find the location by analyzing the shapes (polygons). Would even be easier for me if it was to compare the polylines. Where is this group of polylines located ?

Please see an example attached to illustrate my project.

I thought that this would be possible with all the tools of ArcGis. Maybe another software would do the job (AutoCAD, etc.) but I doubt it. 

In my mind, there must be a solution! If the question has to be posted somewhere else, please tell me. 

Thank you very much for your help.

ExGeoTique

0 Kudos
1 Solution

Accepted Solutions
DavidPike
MVP Frequent Contributor

If the relative positions of the vertices are exactly the same:

ensure both are shapefiles or feature classes 

iterate through the geometries of the big shapefile's polylines (@SHAPE token) with an arcpy.da.searchCursor

do some maths on the vertices within the geometry - something like divide all the y values by the smallest y value present, and same for x values.  This will allow you to compare relative geometries even though the initial coordinates are different (I guess).

append these values, and the ObjectID (@OID token) as a list of lists (or similar).

 

run the same geometry search cursor operations on the arbitrary coordinate CAD feature, then when you have the relative geometries, compare these to the list you created prior, and grab matching OIDs.

 

View solution in original post

6 Replies
DavidPike
MVP Frequent Contributor

Hi,

What is the projection of the second shapefile? You can project it to the same as the 'big' shapefile.

I guess the pictures will explain it better but they just show as 'virus scan in progress' for me and I can't open them.

I'd certainly say you could find triangles and quadrilaterals easily enough by looking at the geometries, but 'perfect' squares and triangles would have to be fuzzy-matched in a more complex process as they are unlikely to be digitized exactly.  Bringing projection geometry shifts into the mix could also warp the features.

0 Kudos
ExGeoTique
Emerging Contributor

Hey!

Thank you for the reply.

Unfortunately, the files appears the same to me 😞 : "virus scan in progress".

Yes, the second shapefile would be in the same projection as the "big file" shapefile. Otherwise, I'm pretty sure it would be impossible 🙂 to match them.

Yes, looking at the geometries, this is what I thought I'd need use. However, how don't really know how to process. I found the tool "Feature compare", but I'm not sure if it will do the job. My attribute tables are not equivalent at all since the shapefiles come from 2 different sources. In fact, one of them is a DWG which doesn't have any attribute table I believe. I don't know how I should properly convert the DWG to a SHP.

In this tool "Feature Compare", I could compare "GEOMETRY_ONLY". Can I use this even though the attribute tables are not the same ? How ?

I've uploaded the files to my personal drive in the cloud. Please tell me if you see them.

https://1drv.ms/u/s!AlAC_yY_W7j04C6YCQOMCkzUheyv?e=tP4wbO

Thank you very much again.

ExGeoTique

0 Kudos
DavidPike
MVP Frequent Contributor

the dwg is a CAD file right? The dwg is located somewhere else entirely but you want to find similar shaped buildings or exactly the same shape in other areas?

0 Kudos
ExGeoTique
Emerging Contributor

Correct. The DWG is a CAD file.

And yes, it is located somewhere else entirely (because it has arbitrary coordinates). However, it is in the same projection. So, the shapes in the "big file" and the other file are exactly the same. So, I want to find the exact location in the big file comparing the exact same geometries

My first analogy with squares and triangle was maybe not the best. Let's see this one:

In fact, I could compare it as a big puzzle (big file). The puzzle being composed of different pieces (properties boundaries). Where are these little pieces (other file) going as a block in the big puzzle ? Because, if I had only one piece, a lot of pieces can look exactly the same. But the more pieces I have together (here, I'd have only 2 pieces - one small property and a bigger one in the back with a different orientation - see picture), the easier I believe it would be to find it's location in the big file which is georeferenced with coordinates. 

Once I'll found its location, I'll be able to know its coordinates since the big file has coordinates. 

I hope that I'm clear enough and that I'm not just making it harder to understand with this new analogy. 🙂 

ExGeoTique

0 Kudos
DavidPike
MVP Frequent Contributor

If the relative positions of the vertices are exactly the same:

ensure both are shapefiles or feature classes 

iterate through the geometries of the big shapefile's polylines (@SHAPE token) with an arcpy.da.searchCursor

do some maths on the vertices within the geometry - something like divide all the y values by the smallest y value present, and same for x values.  This will allow you to compare relative geometries even though the initial coordinates are different (I guess).

append these values, and the ObjectID (@OID token) as a list of lists (or similar).

 

run the same geometry search cursor operations on the arbitrary coordinate CAD feature, then when you have the relative geometries, compare these to the list you created prior, and grab matching OIDs.

 

ExGeoTique
Emerging Contributor

This look like a great solution! 

I'll have to try to make something out of this as I'm a beginner with ArcGIS. I've already done some Python before, just need to put this all together.

I'll go step by step. Probably starting with small shapes see if it works.

I completely understand your thought process. It makes sense to make the comparison on the vertices. 

Thank you again!

ExGeoTique