[R-sig-Geo] Need to merge .RDS dataframe and India Shape file, and then plot yield map with tile legend

Ranjeet Kumar Jha r@njeetjh@||tkgp @end|ng |rom gm@||@com
Thu May 12 09:02:31 CEST 2022


Hello Roger,

I really appreciate your support and help! Now I have uploaded all the
required .shx, .dbf, and .prj files in the link folder.

https://drive.google.com/drive/folders/1dNmGTI8_c9PK1QqmfIjnpbyzuiCXgxFC?msclkid=4816425dd04111ec912cf8b4175aa93c

On Wed, May 11, 2022 at 5:42 PM Roger Bivand <Roger.Bivand using nhh.no> wrote:

> On Tue, 10 May 2022, Ranjeet Kumar Jha wrote:
>
> > Hello Roger,
> >
> > Thanks for your kind reply! I am going through this. However, sharing the
> > link of code, shape file and .rds data frame for better understanding and
> > helping through the real files.
>
> District_sim.shp must of course be accompanied by District_sim.shx,
> District_sim.dbf and most likely District_sim.prj, which are absent.
>
> Roger
>
> >
> >
> https://drive.google.com/drive/folders/1dNmGTI8_c9PK1QqmfIjnpbyzuiCXgxFC?msclkid=4816425dd04111ec912cf8b4175aa93c
> >
> > Regards and Thanks,
> > Ranjeet
> >
> > On Tue, May 10, 2022 at 1:34 PM Roger Bivand <Roger.Bivand using nhh.no>
> wrote:
> >
> >> On Tue, 10 May 2022, Ranjeet Kumar Jha wrote:
> >>
> >>> Hello Everyone,
> >>>
> >>> I am trying to plot an Indian district shapefile filled with modeled
> >> yield,
> >>> corresponding to each GDMID. I needed to first merge the Yield data
> with
> >>> respect to each GDMID from the .RDS file with the district shapefile of
> >>> India. Each district is represented by a GDMID. After merging, the
> Indian
> >>> district map filled with modeled yield values needs to be plotted
> similar
> >>> to an example attached figure. Shape file has five features, and one of
> >>> them is "GDMID".
> >>
> >> The code is not a reproducible example; it needs to run with no
> reference
> >> to local directories. The use of tibbles or other misunderstandings
> >> represents state.ID and GDMID as numeric, they should be character, you
> >> cannot do arithmetic on them. The level 2 boundaries from
> >> https://geodata.ucdavis.edu/gadm/gadm4.0/gpkg/gadm40_IND.gpkg do not
> use
> >> GDMID, so unless you provide a download link to your boundaries, no-one
> >> can help. Also, your data.frame has 694 observations, GADM has 666.
> >>
> >> My guess is that you have found a blog somewhere, probably very
> >> out-of-date (you use rgdal::readOGR() not sf::st_read()), and which is
> >> causing lots of problems, because it complicates things.
> >>
> >> Use the sf package, avoid tidyverse which can convert representations
> >> without asking, make sure that the IDs are character not numeric (to
> >> preserve any leading zeros), and use tmap or mapsf not ggplot (much
> >> simpler and more intuitive interface for mapping).
> >>
> >> See https://geocompr.robinlovelace.net/ and the sf vignettes. Once you
> >> have control of the IDs (for example try match() to see if they do match
> >> in type and value). sf has a merge method, which gives a good deal of
> >> control.
> >>
> >> Hope this helps,
> >>
> >> Roger
> >>
> >>>
> >>> I feel there is something wrong with my code for merging and plotting
> by
> >>> ggplot.
> >>>
> >>> I have attached herewith my code, and RDS data-frame.
> >>>
> >>> It would be great if you could help me with merging issue and plotting
> >> the
> >>> map, showing yield value with legend in tile format.
> >>>
> >>> Regards and Thanks,
> >>> Ranjeet
> >>>
> >>>
> >>
> >> --
> >> Roger Bivand
> >> Emeritus Professor
> >> Department of Economics, Norwegian School of Economics,
> >> Postboks 3490 Ytre Sandviken, 5045 Bergen, Norway.
> >> e-mail: Roger.Bivand using nhh.no
> >> https://orcid.org/0000-0003-2392-6140
> >> https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
> >>
> >
> >
> >
>
> --
> Roger Bivand
> Emeritus Professor
> Department of Economics, Norwegian School of Economics,
> Postboks 3490 Ytre Sandviken, 5045 Bergen, Norway.
> e-mail: Roger.Bivand using nhh.no
> https://orcid.org/0000-0003-2392-6140
> https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
>


-- 
Ranjeet  Kumar Jha, M.Tech. (IIT Kharagpur), Ph.D. (USA)
https://www.linkedin.com/in/ranjeet-kumar-jha-ph-d-usa-73a5aa56
-----------------------------------------------------------
Email: *ranjeetjhaiitkgp using gmail.com <ranjeetjhaiitkgp using gmail.com>*


*"Simple Heart, Humble Attitude and Surrender to Supreme Being make our
lives beautiful!"*

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list