- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi everyone
Does anyone know, if it is possible to spatial match?
What I mean is that I have a shape-file with some polygons, and I have another file with a lot of different coordinates. I want to merge the coordinate-dataset with the shape-file, so the coordinates can get the right polygon.
Does my question make sense? Thanks in advance 😀
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I've had luck in the past with importing the shapefile using PROC MAPIMPORT, and then using PROC GINSIDE to project the coordinates.
Without data, that's all I can give you. Hopefully that helps.
Here's some documentation:
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi maguiremq
Thanks for your reply!
I tried your suggestion, but I could not really get it to work... If you don't mind, you could try it out?
The shapes I'm trying to spatial match are from this site https://www.efgs.info/data/ under "Denmark".
I did have luck using "proc mapimport". I have taken a subset of this:
data WORK.SHAPE;
infile datalines dsd truncover;
input X 7. Y 9. SEGMENT 1. GRD_NEWID:$25.;
datalines;
4442000 3519000 1 1kmN3519E4441
4441000 3519000 1 1kmN3519E4441
4441000 3520000 1 1kmN3519E4441
4442000 3520000 1 1kmN3519E4441
4442000 3519000 1 1kmN3519E4441
;;;;
run;
The dataset I want to match it with is the following:
data WORK.EDMT;
infile datalines dsd truncover;
input DDKNcelle1km $12. wgs84_bredde 14. wgs84_laengde 12.;
datalines;
1km_6072_684 54.765037537 11.871144295
1km_6072_684 54.765060425 11.871236801
1km_6072_684 54.765117645 11.871257782
1km_6072_684 54.765144348 11.871356964
1km_6072_684 54.765148163 11.870749474
1km_6072_684 54.765159607 11.870833397
1km_6072_684 54.765193939 11.871382713
1km_6072_684 54.765197754 11.871330261
1km_6072_684 54.765220642 11.870867729
;;;;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Sorry, I missed this one in my inbox.
I just did my own test run on my own data, and this is what I did.
proc import
datafile = "/your/data/here/"
out = needs_geo (rename = (longitude = x latitude = y))
dbms = csv
replace;
guessingrows = 5000;
run;
proc mapimport
datafile = "/your/shape/file"
out = shape;
run;
proc sort
data = needs_geo;
by x y;
run;
proc sort
data = shape;
by x y;
run;
proc ginside
map = shape
data = needs_geo
out = needs_geo_w_shape;
id var-you-want-from-shape-file;
run;
I am by no means advanced with mapping -- it's something I've learned on my own, and I have a crude working knowledge on how things work.
I would recommend renaming your respective latitude and longitude coordinates on your EDMT dataset to x and y (as I do on the PROC IMPORT).
Essentially, just use my code and tailor it to your data set. Let me know if there are any issues. It worked for me, but I would be careful and check everything to make sure it makes sense. My own local data seemed to make sense.