3

I have an empty raster shapefile that only contains the latitude and the longitude of the centroids of each grid.

I now want to add an extra variable to each grid cell coming from a cvs or txt file. In this text file, latitude and longitude of the centroid of each grid is also included. Even though the information is given per centroid, the information relates to the entire grid cell (so each grid cell should be colored for 100% with one color / value).

Afterwards, I save the joined result again in a shapefile.

My data (MyData.cvs) and grid shapefile (grid_025dd.shp) can be found through the following link: https://drive.google.com/folderview?id=0By9u5m3kxn9yfjZtdFZLcW82SWpzT1VwZXE1a3FtRGtSdEl1c1NvY205TGpack9xSFc2T2s&usp=sharing

I would like to use R to do this merge because I need the shapefile, with the information of the variable, afterwards to continue my analysis in R. However, I do have ArcGis on my computer in case that R can't do the job. In that case, ArcGis could maybe make one shapefile with all the information so that I can use that in R.

I think the main reason why I don't manage solving this (basic?) issue is that I don't know how to handle the two column coordinates (one for longitude and one for latitude). Previously, I have always worked with one common ID in both the text file and the shapefile. Now I have two columns that form together the ID to merge both data.

Could someone help me with this? I have some experience with R but I am a beginner in ArcGis (yet, willing to learn!).

2 Answers 2

3

This is a reasonably simple problem to solve in ArcGIS.

  1. Open the Shapefile (it's not a "raster shapefile" btw; there's no such thin).
  2. Add two fields to your shapefile. One for Lat, one for Lon. Both should be of type Float or double.
  3. Populate one of these fields with the X, and one with the Y value for the point. (Using "calculate geometry").

  4. Now, create a third field of type "text" and use the "field calculator" to populate it with [Lat][Lon] - this will create a single string which has both lat and lon in.

Using Excel, or a decent notepad thing

  1. Concatenate the Latitude and Longitude into a single string as we've just done in step 4. The result is that we have a unique Identifier.

ArcGIS again.

  1. You can now use the Join And Relates -> Join feature and join using this column.
  2. Once joined, export the shapefile and it will now include the CSV data.
3
  • 1
    step 5 : you could also concatenate (str(!lat!)+ str(!long!) )in Python syntax) in the field calculator to avoid using multiple softwares
    – radouxju
    Jul 23, 2015 at 10:51
  • @radouxju Yep, but I was being lazy and avoiding googling that string up. Thanks for supplying it. :-) Jul 23, 2015 at 11:04
  • Thank you very much @GIS-Jonathan and radouxju for your feedback and help! It works perfectly for me and now I can continue! Really appreciate your help!
    – user33125
    Jul 23, 2015 at 12:17
2

I think another way of doing this is to just add the text file to ArcMap, display by x,y coordinates, and join to your to your original shapefile. You can then export the resulting shapefile (or just the table) as whatever you want.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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