Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "cells": [
- {
- "cell_type": "code",
- "execution_count": 13,
- "metadata": {
- "collapsed": false
- },
- "outputs": [],
- "source": [
- "import sys\n",
- "\n",
- "import geopandas as gpd\n",
- "from PIL import Image\n",
- "\n",
- "sys.path.insert(0,'/home/alan/git/drago')\n",
- "import drago\n",
- "\n",
- "src_image = '/media/alan/storage/data/dgcs/china/airfield_images/af007_z17/af007_z17.TIF'\n",
- "objects_filename = '/media/alan/storage/data/dgcs/china/tyler/Aircraft_Training_Data.shp'\n",
- "dst_filename = '/home/alan/Desktop/tmp.jpg'\n",
- "\n",
- "# Load shapefile\n",
- "objects_df = gpd.read_file(objects_filename)\n",
- "\n",
- "# Load input tiff image\n",
- "tiff = drago.imagery.TiffReader(src_image)\n",
- "\n",
- "# Convert objects into TIFF coordinates (including CRS)\n",
- "objects_df_imcoords = tiff.geopandas2imcoords(objects_df)\n",
- "\n",
- "# Convert to MarkedImage\n",
- "mim = drago.markedimage.MarkedImage(tiff.load_image(), objects_df_imcoords)\n",
- "\n",
- "# Save the mask\n",
- "mask_img = Image.fromarray(mim.mask())#.astype('uint8')\n",
- "mask_img.save()"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- },
- "language_info": {
- "codemirror_mode": {
- "name": "ipython",
- "version": 3
- },
- "file_extension": ".py",
- "mimetype": "text/x-python",
- "name": "python",
- "nbconvert_exporter": "python",
- "pygments_lexer": "ipython3",
- "version": "3.4.3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 2
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement