Extract Lat/lon from Shapefiles

17 views (last 30 days)
Igor Noberto
Igor Noberto on 18 Jun 2015
Edited: Igor Noberto on 29 Jun 2015
I have a grid projected in a Cartesian coordinate where each point represents a portion of a terrain. And I'd like to know the distance between each of these points to the closest road.
These roads are in a shapefile, and the function I'm using ipdm needs a XY input (as my grid point in Cartesian coordinates). So, my thinking is somehow extract the lat/lon of the roads, convert to a projected coordinate, ad then use the ipdm .
Any thoughts?

Answers (1)

Chad Greene
Chad Greene on 18 Jun 2015
You should be able to use shaperead with the 'UseGeoCoords',false option to get roads in cartesian coordinates. Just make sure the projection associated with the shapefile is the same projection you're using for your data.
  3 Comments
Chad Greene
Chad Greene on 24 Jun 2015
I assume the road coordinates are in a structure array, so I wouldn't expect scatter(roads.X,roads.Y) to plot all the roads. What happens if you do
[X,Y] = polyjoin(roads.X,roads.Y);
plot(X,Y)
Igor Noberto
Igor Noberto on 29 Jun 2015
Edited: Igor Noberto on 29 Jun 2015
using this, I received:
Error using polyjoin
Expected input number 1, LATCELLS, to be one of these types:
cell
Instead its type was double.
Error in polyjoin (line 20)
validateattributes(latcells,{'cell'},{'vector'},mfilename,'LATCELLS',1)
Error in script11 (line 22)
[x,y] = polyjoin(X,Y);
Then, I made the double to cell conversion using num2cell, but I got the same result from the post above.
I'm not sure what I'm doing wrong.
these are the roads contents:
>> roads
roads =
6492x1 struct array with fields:
Geometry
BoundingBox
X
Y
id
br
uf
codigo
local_de_i
local_de_f
km_inicial
km_final
extensao
superficie
federal_co
federal__1
federal__2
estadual_c
superfic_1
mpv_082_20
concessao_

Sign in to comment.

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!