# ThinkGeo.Core Image generation using NAIP

**URL:** <https://community.thinkgeo.com/t/thinkgeo-core-image-generation-using-naip/9861>\
**Category:** ThinkGeo Cloud\
**Created:** [July 22, 2020, 6:42am UTC](https://community.thinkgeo.com/t/thinkgeo-core-image-generation-using-naip/9861 "2020-07-22T06:42:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![MyAgDevTeam](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/m/eb8c5e/32.png) [@MyAgDevTeam](https://community.thinkgeo.com/u/MyAgDevTeam)\
**Post date:** [July 22, 2020, 6:42am UTC](https://community.thinkgeo.com/t/thinkgeo-core-image-generation-using-naip/9861/1 "2020-07-22T06:42:41Z")

</div>

We want to integrate NAIP Imagery in our system.  
for this we need to create map server Tile using RectangleShape or latitude and longitude details.  
how to generate map server tile’s X,Y and Z values?

---

<div class="post-metadata">

**Author:** ![Frank4](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/frank4/32/25224_2.png) [@Frank4](https://community.thinkgeo.com/u/Frank4)\
**Post date:** [July 22, 2020, 6:23pm UTC](https://community.thinkgeo.com/t/thinkgeo-core-image-generation-using-naip/9861/2 "2020-07-22T18:23:29Z")

</div>

Thanks,  
The web api product support this. Here is the samples. [https://samples.thinkgeo.com/webapi/#Openlayers-Layers](https://samples.thinkgeo.com/webapi/#Openlayers-Layers) You can download the sample here  
[https://gitlab.com/thinkgeo/public/thinkgeo-web-maps/-/tree/master/samples/web-api/LayersSample](https://gitlab.com/thinkgeo/public/thinkgeo-web-maps/-/tree/master/samples/web-api/LayersSample)

You will find we have the method to get the tile by x,y,z

```
    // Draw the map and return the image back to client in an IActionResult.
    private IActionResult DrawTileImage(LayerOverlay layerOverlay, int z, int x, int y)
    {
        using (GeoImage image = new GeoImage(256, 256))
        {
            GeoCanvas geoCanvas = GeoCanvas.CreateDefaultGeoCanvas();
            RectangleShape boundingBox = WebApiExtentHelper.GetBoundingBoxForXyz(x, y, z, GeographyUnit.Meter);
            geoCanvas.BeginDrawing(image, boundingBox, GeographyUnit.Meter);
            layerOverlay.Draw(geoCanvas);
            geoCanvas.EndDrawing();

            byte[] imageBytes = image.GetImageBytes(GeoImageFormat.Png);

            return File(imageBytes, "image/png");
        }
    }

```

Thanks

Frank

---

<div class="post-metadata">

**Author:** ![MyAgDevTeam](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/m/eb8c5e/32.png) [@MyAgDevTeam](https://community.thinkgeo.com/u/MyAgDevTeam)\
**Post date:** [July 23, 2020, 5:55am UTC](https://community.thinkgeo.com/t/thinkgeo-core-image-generation-using-naip/9861/3 "2020-07-23T05:55:04Z")

</div>

Thanks Frank for quick reply.  
We do not have x,y and z value to create tile. We only have Rectangle shape data and Latitude Longitude details.  
We want to know how we can use these details to calculate x,y and z value.

---

<div class="post-metadata">

**Author:** ![Frank4](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/frank4/32/25224_2.png) [@Frank4](https://community.thinkgeo.com/u/Frank4)\
**Post date:** [July 23, 2020, 4:42pm UTC](https://community.thinkgeo.com/t/thinkgeo-core-image-generation-using-naip/9861/4 "2020-07-23T16:42:10Z")

</div>

Thanks,  
Basically you don’t need know the XYZ value. The client application will tell you XYZ it needed.  
Here is more information about the XYZ tile system.

[https://wiki.openstreetmap.org/wiki/Slippy\_map\_tilenames](https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames)

So the client application will ask give me the X,Y, Z tile. The server side just generate the tile base on the X,Y,Z value. This is how most application works.

If you real want to use rectangle shape data and Latitude Longitude to calculate the X,Y,Z. The input information is not enough. You need at least specify the z value.That mean you need specify rectangle shape(extent) and the zoom level(Z) to get all tiles in current extent and zoom level.

TileMatrix tileMatrix = new TileMatrix(mapView1.ZoomLevelSet.ZoomLevel07.Scale, 256, 256, MaxExtents.OsmMaps, GeographyUnit.Meter); // This one spcify the zoom level  
var tiles = tileMatrix.GetIntersectingCells(mapView1.CurrentExtent); // This one specify the extent.

It return multiple tiles with X,Y value.

Thanks

Frank
