MATLAB Answers

From vector data to raster

4 views (last 30 days)
SChow on 21 Jan 2020
I am trying to convert a vector data corresponding to countries in a shapefile to raster at 0.1 degree resolution,
For this I am using
functions. Here is what i was trying but MatLab throws up an error.
%%%%here states is a shapefile of the world.
lat = [states.Y]; %%lat and lon are of size 30032x1 each and there are 246 countries in the shapefile
lon = [states.X];
%%%% I convert it to a matrix of 0.1 degree resolution
[Z, R] = vec2mtx(lat, lon, ...
10, [-90 90], [-180 180], 'filled');
%%%% The same shapefile has an attribute of literacy rate for each country, to convert the literacy rate at 0.1 degree resolution, keeping the
%%%% value constant within each country,
Z = imbedm(lat, lon, [states.Lit2005], Z, R)
Error using imbedm (line 53)
Function imbedm expected its LAT, LON, and VALUE inputs to have the same size.


Sign in to comment.

Answers (0)

Translated by