[R-sig-Geo] Overlapping a grid shapefile with a NUTS3 shapefile to determine one average value for each NUTS3 region

Linus Holtermann holtermann at hwwi.org
Wed Jul 22 11:48:54 CEST 2015


Sorry,

the right command is "exctract", of course.

Mit freundlichen Grüßen


Linus Holtermann
Hamburgisches WeltWirtschaftsInstitut gemeinnützige GmbH (HWWI)
Heimhuder Straße 71
20148 Hamburg
Tel +49-(0)40-340576-336
Fax+49-(0)40-340576-776
Internet: www.hwwi.org
Email: holtermann at hwwi.org
 
Amtsgericht Hamburg HRB 94303
Geschäftsführer: PD Dr. Christian Growitsch | Prof. Dr. Henning Vöpel
Prokura: Dipl. Kauffrau Alexis Malchin
Umsatzsteuer-ID: DE 241849425


-----Ursprüngliche Nachricht-----
Von: R-sig-Geo [mailto:r-sig-geo-bounces at r-project.org] Im Auftrag von Linus Holtermann
Gesendet: Mittwoch, 22. Juli 2015 11:46
An: Janka Vanschoenwinkel; r-sig-geo at r-project.org
Betreff: Re: [R-sig-Geo] Overlapping a grid shapefile with a NUTS3 shapefile to determine one average value for each NUTS3 region

Hello,

take a look at the "overlay" command in the raster-package. Weight=TRUE may be a step in the right direction for your problem.

Bests,



Linus Holtermann
Hamburgisches WeltWirtschaftsInstitut gemeinnützige GmbH (HWWI) Heimhuder Straße 71
20148 Hamburg
Tel +49-(0)40-340576-336
Fax+49-(0)40-340576-776
Internet: www.hwwi.org
Email: holtermann at hwwi.org
 
Amtsgericht Hamburg HRB 94303
Geschäftsführer: PD Dr. Christian Growitsch | Prof. Dr. Henning Vöpel
Prokura: Dipl. Kauffrau Alexis Malchin
Umsatzsteuer-ID: DE 241849425


-----Ursprüngliche Nachricht-----
Von: R-sig-Geo [mailto:r-sig-geo-bounces at r-project.org] Im Auftrag von Janka Vanschoenwinkel
Gesendet: Mittwoch, 22. Juli 2015 11:37
An: r-sig-geo at r-project.org
Betreff: [R-sig-Geo] Overlapping a grid shapefile with a NUTS3 shapefile to determine one average value for each NUTS3 region

Dear listmembers!


I would like to add the average value of, let’s say soil moisture, to each
NUTS3 region. However, soil moisture values are stored in little grids.
Therefore, I need to find a way to calculate which grids overlap with a certain NUTS3 region in order to determine the average soil moisture value for that NUTS3 region. Visually, it can be compared to this picture where little grids approximate together the shape of US states:
http://fieldguide.mt.gov/RangeMaps%5CESMapQUAD_9217.jpg


It is possible that one NUTS3 region consists of 2 full grids and 3 half grids, while another NUTS3 region consists of only a 0.75 grid. It is also possible that some grids are empty because I don’t have values there.


I assume that this requires 3 steps (but I am actually not sure):


   - Step 1 would be to add the values of the text file to the grid
   shapefile
   - Step 2 would be to overlap the grid shapefile with the empty nuts3
   shapefile
   - Step 3 would be to write a new nuts3 shapefile which contains the
   overlapped values

My data and shapefiles can be found through the following link:

https://drive.google.com/folderview?id=0By9u5m3kxn9yfjZtdFZLcW82SWpzT1VwZXE1a3FtRGtSdEl1c1NvY205TGpack9xSFc2T2s&usp=sharing


   - mydata = read.csv("MyData.csv", header = TRUE) #contains coordinates
   in latitude and longitude form that represent the centroids of each
   “grid”.  #mydata also contains 1 variable (random numbers in this case)
   that I want to match to the nuts3 regions in the “nuts” shapefile
   - library(rgdal)
   - grid <- readOGR(".", layer = "grid_025dd") #each grid contains de
   centroid coordinates that should be linked to mydata in order to fill all
   the grids with the variable of mydata
   - nuts <- readOGR(".", layer = "NUTS_RG_60M_2006")

Currently, I am nowhere. Maybe I don’t use the right keywords to google, but mostly, I am not used to working with coordinates. In the previous maps that I made, I was always capable of using some sort of objectid common to the data and the shapefile. Now, this is not the case. There should be an easy way to tell R to use the coordinates of mydata and combine them with the coordinates of the grids, but I can’t figure it out.


Another issue that I face is that the values of the grids in ‘mydata’
should fill up an entire grid. Yet, R recognizes the values as point values.



Could someone please help me and point me in the correct direction for step
1 and 2? I think I should be able to do step 3 on my own.

Thanks a lot for your help! I appreciate it a lot!



Dear kindness,


Janka

	[[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo at r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo at r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


More information about the R-sig-Geo mailing list