<p>I would suggest using cdo for your purpose. At least for variables, which values are independent of the grid cell size, one can use cdo.</p>

<h1>cdo</h1>

<p>cdo (Climate Data Operators) is a command line program to process netCDF and GRIB files. It is developed an maintained by Uwe Schulzweida and colleagues at the Max-Planck Institute for Meteorology in Hamburg, Germany. </p>

<ul>
<li><a href="https://code.mpimet.mpg.de/projects/cdo/" rel="nofollow noreferrer">cdo Homepage</a></li>
<li><a href="https://code.mpimet.mpg.de/projects/cdo/embedded/index.html" rel="nofollow noreferrer">cdo HTML Manual</a></li>
<li><a href="https://code.mpimet.mpg.de/projects/cdo/boards" rel="nofollow noreferrer">cdo Forum</a></li>
</ul>

<p>cdo provides different operators to process your data. You can chain several operators in one command. You always start with the call of cdo. Examples:</p>

<pre><code>cdo OPERATOR1 -OPERATOR2 -OPERATOR3 inputfile1.nc inputfile2.nc outputfile.nc
cdo OPERATOR1 -OPERATOR2 inputfile1.nc -OPERATOR3 inputfile2.nc outputfile.nc
</code></pre>

<p>The first operator is just appended to <code>cdo</code>. All further appended operators need to have <code>-</code> as suffix.</p>

<h2>example</h2>

<p>Assume, we have two files (<code>file1.nc</code> and <code>file2.nc</code>) with some ocean data (<code>sst</code>, <code>salinity</code>, <code>u</code>, <code>v</code>, ...). We want to calculate the difference between the <code>sst</code> of both files. This is done via</p>

<pre><code>cdo diff -selname,sst file1.nc -selname,sst file2.nc outfile.nc
</code></pre>

<p>We could do this also in four steps:</p>

<pre><code>cdo selname,sst file1.nc sst_of_file1.nc
cdo selname,sst file2.nc sst_of_file2.nc
cdo diff sst_of_file1.nc sst_of_file2.nc outfile.nc
</code></pre>

<h1>Interpolate data with cdo without considering grid cell size</h1>

<p>cdo provides different operators for interpolation. <code>REMAPBIL</code> for bilinear interpolat, <code>REMAPNN</code> for nearest-neighbor interpolation, and so on. They are listed in the manual. I use <code>remapbil</code> here as an example.</p>

<pre><code>cdo remapbil,NEW_GRID_DEF file_old_grid.nc file_new_grid.nc
</code></pre>

<p>The <code>file_old_grid.nc</code> is your input file and <code>file_new_grid.nc</code> is your output file. Here you find an example from my work at GitHub:</p>

<ul>
<li><a href="https://github.com/neumannd/WorkingExamples/tree/master/bash/03_interpolate2CMAQ" rel="nofollow noreferrer">cdo remapbil example</a></li>
</ul>

<p>The grid definition on your input file <code>file_old_grid.nc</code> needs to be recognized by cdo. To test, whether it is recognized you can try</p>

<pre><code>cdo griddes file_old_grid.nc
</code></pre>

<p>If it prints out the correct grid definition, then everything is fine. If not, you need to correct the definition of your lon-lat grid. Please have a look in the respective section below for details.</p>

<p>The <code>NEW_GRID_DEF</code> is a file, in which the target grid is described. If your target grid is a nicely defined grid, you can write this file by hand. E.g. it could look like (copied from the HTML manual of cdo):</p>

<pre><code>gridtype = lonlat 
xsize    =   60 
ysize    =   30 
xfirst   = -177 
xinc     =    6 
yfirst   =  -87 
yinc     =    6 
</code></pre>

<p>Please look for "CDO grid" and "grid description" in the <a href="https://code.mpimet.mpg.de/projects/cdo/embedded/index.html" rel="nofollow noreferrer">cdo HTML Manual</a> to fine more examples and explanation on it.</p>

<p>If you don't have a nicely defined grid, you can generate your <code>NEW_GRID_DEF</code>. This is, what I have often done, because our chemistry transport model setup needed a non-nicely defined grid. </p>

<pre><code>cdo griddes file_with_wrf_grid_definition.nc &gt; NEW_GRID_DEF
</code></pre>

<p>In <code>file_with_wrf_grid_definition.nc</code>, the model grid has to be defined and it needs to be recognized by cdo. Here you find an example from my work at GitHub:</p>

<ul>
<li><a href="https://github.com/neumannd/WorkingExamples/tree/master/bash/02_makeGridDef" rel="nofollow noreferrer">cdo make grid definition</a></li>
</ul>

<h2>How to make cdo recognize</h2>

<p>cdo assumes that your file conforms with the CF Conventions (<a href="http://cfconventions.org/" rel="nofollow noreferrer">Climate and Forecast Conventions</a>). Please have a look in the respective chapter of the CF Conventions Document to get a general description.</p>

<p>A working grid definition could look as follows (as ncdump output):</p>

<pre><code>dimensions:
  time = UNLIMITED ; // (1 currently)
  lay = 1 ;
  lat = 78 ;
  lon = 62 ;
variables:
  float lat(lat, lon) ;
          lat:long_name = "latitudes       " ;
          lat:units = "degree north    " ;
          lat:var_desc = "latitude (south negative)                                                       " ;
          lat:cell_methods = "TSTEP, LAY: mean" ;
  float lon(lat, lon) ;
          lon:long_name = "longitudes      " ;
          lon:units = "degree east     " ;
          lon:var_desc = "longitude (west negative)                                                       " ;
          lon:cell_methods = "TSTEP, LAY: mean" ;
  float DATA_VAR(time, lay, lat, lon) ;
          DATA_VAR:long_name = "some long var name" ;
          DATA_VAR:units = "some unit" ;
          DATA_VAR:var_desc = "some description" ;
          DATA_VAR:coordinates = "lat lon" ;
</code></pre>

<p>The important aspect is that the data variable has an attribute <code>coordinates</code>, which value contains the two lon and lat dimensional variables (I attached a second example so that it becomes clear). Additionally, the <code>standard_name</code> and <code>units</code> attributes should be properly set at the dimensional variables.</p>

<pre><code>dimensions:
  time = UNLIMITED ; // (1 currently)
  lay = 1 ;
  lat = 78 ;
  lon = 62 ;
variables:
  float lat_1(lat, lon) ;
          lat_1:long_name = "latitudes       " ;
          lat_1:standard_name = "latitudes       " ;
          lat_1:units = "degree north    " ;
          lat_1:var_desc = "latitude (south negative)                                                       " ;
  float lon_1(lat, lon) ;
          lon_1:long_name = "longitudes      " ;
          lon_1:standard_name = "longitudes      " ;
          lon_1:units = "degree east     " ;
          lon_1:var_desc = "longitude (west negative)                                                       " ;
  float DATA_VAR(time, lay, lat, lon) ;
          DATA_VAR:long_name = "some long var name" ;
          DATA_VAR:standard_name = "the standard name" ;
          DATA_VAR:units = "some unit" ;
          DATA_VAR:var_desc = "some description" ;
          DATA_VAR:coordinates = "lat_1 lon_1" ;
</code></pre>

<h1>Interpolate data with cdo with considering grid cell size</h1>

<p>No idea how it works with cdo</p>

CC BY-SA 4.0
2018-06-11T14:04:58.763Z
Hello,daniel. When thinking again this problem, since the unit of Hestia is `Kg`, I `remapbil` it to a `87*87` domain directly, it seems the result is a little strange. The maximum decreased from `169857` to `2771` Kg. Is it because of without considering the grid cell area or something else? However, when I first use `gridboxsum,5,5` commond and then `remapbil`, the maximum of data just decrease to `124262` Kg. I am confused about that?
Allen Zhang
CC BY-SA 4.0
2018-06-11T14:15:29.347Z
On the other hand, It looks like we can use `gridarea` to calculate the `cell_area`, and then merge it  to the file, then use `expr`with`new_variable=original_variable/cell_area` to get a `new_variable` with `Kg/m2/h`.But the shape  of `original_variable` is `(time,lat,lon)`,and the shape of `cell_area` is `(lat,lon)`, do you have some experience about how to deal with it?
Allen Zhang
CC BY-SA 4.0
2018-06-12T07:12:06.553Z
it seems that use `cdo div infile.nc -gridarea infile.nc outfile.nc` can get the value of wanted `new_variable`, but I am not sure whether the whole process is right? since after `remapbil`, the maximum value would decrease from `4.46` to `0.073`.
Allen Zhang
CC BY-SA 3.0
2018-03-23T14:10:24.633Z
2018-03-23T14:10:24.633Z
daniel.heydebreck
<p><strong>using R:</strong></p>

<p>Alright,</p>

<p>As you have data with different resolution, I would suggest you to convert your data to raster and resample to match the grid cell of your wrf_inputs. Take care of mass conservation.
Then convert your raster to a matrix, data.frame, or spatial feature of 'POLYGON' your emissions
Then create wrf_chemi files</p>

<p>steps:</p>

<ol>
<li>raster your emissions </li>
<li>raster your wrf_inputs</li>
<li>resample emissions</li>
<li>create data-frames of emissions</li>
<li>create wrf_chemis your domains</li>
<li>put your pollutants in wrf_chemis</li>
</ol>

<p><strong>Please, read the documentation of each R Package</strong>:
<a href="https://CRAN.R-project.org/package=raster" rel="nofollow noreferrer">raster</a>,
<a href="https://ibarraespinosa.github.io/ratmos/" rel="nofollow noreferrer">ratmos</a>,
<a href="https://r-spatial.github.io/sf/" rel="nofollow noreferrer">sf</a>,
<a href="https://atmoschem.github.io/vein/" rel="nofollow noreferrer">vein</a>,
<a href="https://atmoschem.github.io/eixport/" rel="nofollow noreferrer">eixport</a>. </p>

<p>You can raster your data by:</p>

<pre><code>library(raster)
devtools::install_github("ibarraespinosa/ratmos")
library(ratmos)
library(sf)
library(vein)
library(eixport)
r &lt;- raster("emissions.tif") #or .nc, raster will use gdal to know
ri &lt;- raster_wrf("wrfinput_d02")
spplot(ri, scales = list(draw = T)) # check plot
# Then it should be something like this
new_r &lt;- crop(r, ri) # crop your data to the new raster
new_r &lt;- resample(new_r, ri) #check options
df &lt;- st_as_sf(rasterToPolygons(new_r))
# To create Array. Checkif you need to rotate your array
a &lt;- GriddedEmissionsArray(df cols = ncol(ri), rows = nrow(ri), rotate = T) 
# The create your wrfchemi
 wrf_create('wrfinput', 'path_to_wrfchemi', ... , 'pollutants')
#and then put your emissions int the wrfchemi
wrf_put('path_to_wrfchemi', 'name_of_pollutant', a)
</code></pre>

<p><a href="https://i.sstatic.net/HUqHj.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/HUqHj.png" alt="wrfinput"></a></p>

<p>If you need help, drop me an email sergio.ibarra@usp.br</p>

<p>Best, Sergio</p>

CC BY-SA 4.0
2018-10-16T20:28:11.740Z
2018-10-16T20:28:11.740Z
Sergio
<p>Here, I have a regional emission inventory, which mainly contains the varibales of <code>lat</code>,<code>lon</code>,<code>emission</code>,and the <code>emission</code>shape is <code>(lat,lon)</code>.</p>

<p>For example :</p>

<ol>
<li><p><a href="http://db.cger.nies.go.jp/dataset/ODIAC/DL_odiac2017.html" rel="nofollow noreferrer">ODIAC</a>, the  spatial resolution is <code>1*1 deg</code>, and emission shape is <code>(180,360)</code>，units : gC/m2/d;</p></li>
<li><p><a href="http://hestia.project.asu.edu/audience_researchers.shtml" rel="nofollow noreferrer">Hestia</a>, the spatial resolution is <code>0.002*0.002 deg</code>, and the emission shape is <code>(521,560)</code>,units: Kg;</p></li>
</ol>

<p>For now, I have to map the emission from the geographic coordinate <code>(lat,lon)</code> to WRF model grid, which may look like <code>99*99</code> with grid spacing of <code>3km</code>,or <code>87*87</code> with  grid spacing of <code>1km</code>. </p>

<p>It seems that the process of mapping involves the calculation of area of old grid of emission inventory.</p>

<p>I am confused about how to do. Is there any efficient method to deal with it?</p>

<p>Thanks for all the help.</p>

CC BY-SA 3.0
2018-03-22T14:28:34.680Z
The unit of the ODIAC emission inventory is given in `gC/m2/d`. You can interpolate this data set without considering the size of the grid cells. I do such remapping tasks with [cdo](https://code.mpimet.mpg.de/projects/cdo/). If you want to do the same for the Hestia data set with cdo, maybe the option `setgridarea` helps -- but I am not sure. But generally: yes, someone (the program or you) has to calculate the grid cell area.
daniel.heydebreck
CC BY-SA 3.0
2018-03-22T15:21:40.217Z
@daniel.neumann, thanks for your reply, I would try to learn the usage of  `cdo` first.
Allen Zhang
CC BY-SA 3.0
2018-03-22T21:26:53.313Z
I might recommend creating a python script using the Basemap module (https://matplotlib.org/basemap/) to convert both model and emissions geography into x and y coordinates, then interpolate the data from there.
BarocliniCplusplus
CC BY-SA 3.0
2018-03-23T03:15:24.537Z
@BarocliniCplusplus Is there any more detail example for it?
Allen Zhang
CC BY-SA 3.0
2018-03-23T03:55:30.303Z
@daniel.neumann Can you show me some example about the usage of `cdo`. I can't deal with it in python.
Allen Zhang
CC BY-SA 3.0
2018-03-23T08:32:08.437Z
@AllenZhang I will try post one example later on. Quite busy today.
daniel.heydebreck
CC BY-SA 3.0
2018-03-23T14:43:47.213Z
Basemap is used to create maps. You can make a map identical to the WRF grid you use. Examples on how Basemap is commonly used can be found here: https://matplotlib.org/basemap/users/examples.html. I'd then recommend using the scipy interp module(https://docs.scipy.org/doc/scipy/reference/tutorial/interpolate.html) to interpolate your ungridded data to the grid.
BarocliniCplusplus
CC BY-SA 3.0
2018-03-27T12:26:05.813Z
I can provide a code snippet (in R) to calculate the grid cell area if that's of any help. It's probably not really efficient though (to calculate it using an extra tool and then pass it on to cdo)...
Janina
<atmosphere-modelling><air-pollution><wrf><python><wrf-chem>
How to map emission inventory from lat&lon corrdinate to WRF model grid
Allen Zhang
# How to map emission inventory from lat&lon corrdinate to WRF model grid

(Asked by: username_0 on 2018-03-22)

Here, I have a regional emission inventory, which mainly contains the varibales of `lat`,`lon`,`emission`,and the `emission`shape is `(lat,lon)`.

For example :

1. [ODIAC](http://db.cger.nies.go.jp/dataset/ODIAC/DL_odiac2017.html), the spatial resolution is `1*1 deg`, and emission shape is `(180,360)`，units : gC/m2/d;
2. [Hestia](http://hestia.project.asu.edu/audience_researchers.shtml), the spatial resolution is `0.002*0.002 deg`, and the emission shape is `(521,560)`,units: Kg;

For now, I have to map the emission from the geographic coordinate `(lat,lon)` to WRF model grid, which may look like `99*99` with grid spacing of `3km`,or `87*87` with grid spacing of `1km`.

It seems that the process of mapping involves the calculation of area of old grid of emission inventory.

I am confused about how to do. Is there any efficient method to deal with it?

Thanks for all the help.

**Tags:** atmosphere-modelling, air-pollution, wrf, python, wrf-chem

> **Comments:**
> **username_1**: The unit of the ODIAC emission inventory is given in `gC/m2/d`. You can interpolate this data set without considering the size of the grid cells. I do such remapping tasks with [cdo](https://code.mpimet.mpg.de/projects/cdo/). If you want to do the same for the Hestia data set with cdo, maybe the option `setgridarea` helps -- but I am not sure. But generally: yes, someone (the program or you) has to calculate the grid cell area.  
> **username_0**: @daniel.neumann, thanks for your reply, I would try to learn the usage of  `cdo` first.  
> **username_2**: I might recommend creating a python script using the Basemap module (https://matplotlib.org/basemap/) to convert both model and emissions geography into x and y coordinates, then interpolate the data from there.  
> **username_0**: @username_2 Is there any more detail example for it?  
> **username_0**: @daniel.neumann Can you show me some example about the usage of `cdo`. I can't deal with it in python.  
> **username_1**: @username_0 I will try post one example later on. Quite busy today.  
> **username_2**: Basemap is used to create maps. You can make a map identical to the WRF grid you use. Examples on how Basemap is commonly used can be found here: https://matplotlib.org/basemap/users/examples.html. I'd then recommend using the scipy interp module(https://docs.scipy.org/doc/scipy/reference/tutorial/interpolate.html) to interpolate your ungridded data to the grid.  
> **username_3**: I can provide a code snippet (in R) to calculate the grid cell area if that's of any help. It's probably not really efficient though (to calculate it using an extra tool and then pass it on to cdo)...  

---

## 2 answers

### Answer by username_1 on 2018-03-23. Score: 2

I would suggest using cdo for your purpose. At least for variables, which values are independent of the grid cell size, one can use cdo.

# cdo

cdo (Climate Data Operators) is a command line program to process netCDF and GRIB files. It is developed an maintained by Uwe Schulzweida and colleagues at the Max-Planck Institute for Meteorology in Hamburg, Germany.

* [cdo Homepage](https://code.mpimet.mpg.de/projects/cdo/)
* [cdo HTML Manual](https://code.mpimet.mpg.de/projects/cdo/embedded/index.html)
* [cdo Forum](https://code.mpimet.mpg.de/projects/cdo/boards)

cdo provides different operators to process your data. You can chain several operators in one command. You always start with the call of cdo. Examples:

```
cdo OPERATOR1 -OPERATOR2 -OPERATOR3 inputfile1.nc inputfile2.nc outputfile.nc
cdo OPERATOR1 -OPERATOR2 inputfile1.nc -OPERATOR3 inputfile2.nc outputfile.nc

```

The first operator is just appended to `cdo`. All further appended operators need to have `-` as suffix.

## example

Assume, we have two files (`file1.nc` and `file2.nc`) with some ocean data (`sst`, `salinity`, `u`, `v`, ...). We want to calculate the difference between the `sst` of both files. This is done via

```
cdo diff -selname,sst file1.nc -selname,sst file2.nc outfile.nc

```

We could do this also in four steps:

```
cdo selname,sst file1.nc sst_of_file1.nc
cdo selname,sst file2.nc sst_of_file2.nc
cdo diff sst_of_file1.nc sst_of_file2.nc outfile.nc

```

# Interpolate data with cdo without considering grid cell size

cdo provides different operators for interpolation. `REMAPBIL` for bilinear interpolat, `REMAPNN` for nearest-neighbor interpolation, and so on. They are listed in the manual. I use `remapbil` here as an example.

```
cdo remapbil,NEW_GRID_DEF file_old_grid.nc file_new_grid.nc

```

The `file_old_grid.nc` is your input file and `file_new_grid.nc` is your output file. Here you find an example from my work at GitHub:

* [cdo remapbil example](https://github.com/neumannd/WorkingExamples/tree/master/bash/03_interpolate2CMAQ)

The grid definition on your input file `file_old_grid.nc` needs to be recognized by cdo. To test, whether it is recognized you can try

```
cdo griddes file_old_grid.nc

```

If it prints out the correct grid definition, then everything is fine. If not, you need to correct the definition of your lon-lat grid. Please have a look in the respective section below for details.

The `NEW_GRID_DEF` is a file, in which the target grid is described. If your target grid is a nicely defined grid, you can write this file by hand. E.g. it could look like (copied from the HTML manual of cdo):

```
gridtype = lonlat 
xsize    =   60 
ysize    =   30 
xfirst   = -177 
xinc     =    6 
yfirst   =  -87 
yinc     =    6 

```

Please look for "CDO grid" and "grid description" in the [cdo HTML Manual](https://code.mpimet.mpg.de/projects/cdo/embedded/index.html) to fine more examples and explanation on it.

If you don't have a nicely defined grid, you can generate your `NEW_GRID_DEF`. This is, what I have often done, because our chemistry transport model setup needed a non-nicely defined grid.

```
cdo griddes file_with_wrf_grid_definition.nc > NEW_GRID_DEF

```

In `file_with_wrf_grid_definition.nc`, the model grid has to be defined and it needs to be recognized by cdo. Here you find an example from my work at GitHub:

* [cdo make grid definition](https://github.com/neumannd/WorkingExamples/tree/master/bash/02_makeGridDef)

## How to make cdo recognize

cdo assumes that your file conforms with the CF Conventions ([Climate and Forecast Conventions](http://cfconventions.org/)). Please have a look in the respective chapter of the CF Conventions Document to get a general description.

A working grid definition could look as follows (as ncdump output):

```
dimensions:
  time = UNLIMITED ; // (1 currently)
  lay = 1 ;
  lat = 78 ;
  lon = 62 ;
variables:
  float lat(lat, lon) ;
          lat:long_name = "latitudes       " ;
          lat:units = "degree north    " ;
          lat:var_desc = "latitude (south negative)                                                       " ;
          lat:cell_methods = "TSTEP, LAY: mean" ;
  float lon(lat, lon) ;
          lon:long_name = "longitudes      " ;
          lon:units = "degree east     " ;
          lon:var_desc = "longitude (west negative)                                                       " ;
          lon:cell_methods = "TSTEP, LAY: mean" ;
  float DATA_VAR(time, lay, lat, lon) ;
          DATA_VAR:long_name = "some long var name" ;
          DATA_VAR:units = "some unit" ;
          DATA_VAR:var_desc = "some description" ;
          DATA_VAR:coordinates = "lat lon" ;

```

The important aspect is that the data variable has an attribute `coordinates`, which value contains the two lon and lat dimensional variables (I attached a second example so that it becomes clear). Additionally, the `standard_name` and `units` attributes should be properly set at the dimensional variables.

```
dimensions:
  time = UNLIMITED ; // (1 currently)
  lay = 1 ;
  lat = 78 ;
  lon = 62 ;
variables:
  float lat_1(lat, lon) ;
          lat_1:long_name = "latitudes       " ;
          lat_1:standard_name = "latitudes       " ;
          lat_1:units = "degree north    " ;
          lat_1:var_desc = "latitude (south negative)                                                       " ;
  float lon_1(lat, lon) ;
          lon_1:long_name = "longitudes      " ;
          lon_1:standard_name = "longitudes      " ;
          lon_1:units = "degree east     " ;
          lon_1:var_desc = "longitude (west negative)                                                       " ;
  float DATA_VAR(time, lay, lat, lon) ;
          DATA_VAR:long_name = "some long var name" ;
          DATA_VAR:standard_name = "the standard name" ;
          DATA_VAR:units = "some unit" ;
          DATA_VAR:var_desc = "some description" ;
          DATA_VAR:coordinates = "lat_1 lon_1" ;

```

# Interpolate data with cdo with considering grid cell size

No idea how it works with cdo

> **Comments:**
> **username_0**: Hello,daniel. When thinking again this problem, since the unit of Hestia is `Kg`, I `remapbil` it to a `87*87` domain directly, it seems the result is a little strange. The maximum decreased from `169857` to `2771` Kg. Is it because of without considering the grid cell area or something else? However, when I first use `gridboxsum,5,5` commond and then `remapbil`, the maximum of data just decrease to `124262` Kg. I am confused about that?  
> **username_0**: On the other hand, It looks like we can use `gridarea` to calculate the `cell_area`, and then merge it  to the file, then use `expr`with`new_variable=original_variable/cell_area` to get a `new_variable` with `Kg/m2/h`.But the shape  of `original_variable` is `(time,lat,lon)`,and the shape of `cell_area` is `(lat,lon)`, do you have some experience about how to deal with it?  
> **username_0**: it seems that use `cdo div infile.nc -gridarea infile.nc outfile.nc` can get the value of wanted `new_variable`, but I am not sure whether the whole process is right? since after `remapbil`, the maximum value would decrease from `4.46` to `0.073`.  

---

### Answer by username_4 on 2018-10-16. Score: 1

**using R:**

Alright,

As you have data with different resolution, I would suggest you to convert your data to raster and resample to match the grid cell of your wrf\_inputs. Take care of mass conservation.
Then convert your raster to a matrix, data.frame, or spatial feature of 'POLYGON' your emissions
Then create wrf\_chemi files

steps:

1. raster your emissions
2. raster your wrf\_inputs
3. resample emissions
4. create data-frames of emissions
5. create wrf\_chemis your domains
6. put your pollutants in wrf\_chemis

**Please, read the documentation of each R Package**:
[raster](https://CRAN.R-project.org/package=raster),
[ratmos](https://ibarraespinosa.github.io/ratmos/),
[sf](https://r-spatial.github.io/sf/),
[vein](https://atmoschem.github.io/vein/),
[eixport](https://atmoschem.github.io/eixport/).

You can raster your data by:

```
library(raster)
devtools::install_github("ibarraespinosa/ratmos")
library(ratmos)
library(sf)
library(vein)
library(eixport)
r <- raster("emissions.tif") #or .nc, raster will use gdal to know
ri <- raster_wrf("wrfinput_d02")
spplot(ri, scales = list(draw = T)) # check plot
# Then it should be something like this
new_r <- crop(r, ri) # crop your data to the new raster
new_r <- resample(new_r, ri) #check options
df <- st_as_sf(rasterToPolygons(new_r))
# To create Array. Checkif you need to rotate your array
a <- GriddedEmissionsArray(df cols = ncol(ri), rows = nrow(ri), rotate = T) 
# The create your wrfchemi
 wrf_create('wrfinput', 'path_to_wrfchemi', ... , 'pollutants')
#and then put your emissions int the wrfchemi
wrf_put('path_to_wrfchemi', 'name_of_pollutant', a)

```

[![wrfinput](https://i.sstatic.net/HUqHj.png)](https://i.sstatic.net/HUqHj.png)

If you need help, drop me an email username_4.ibarra@usp.br

Best, username_4


---

