Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # coding: utf-8
- # emojiShapeUnicodeArcGISTest
- import fiona #Fiona needed for reading Shapefile
- from fiona.crs import from_epsg
- import shapely.geometry as geometry
- import pyproj #import Proj, transform
- from shapely.ops import transform
- import emoji
- from unicodedata import name as unicode_name
- def extract_emojis(str):
- #str = str.decode('utf-32').encode('utf-32', 'surrogatepass')
- return list(c for c in str if c in emoji.UNICODE_EMOJI)
- #Example Emojis
- emojistring = '😍 test text ❤️👨⚕️'
- emojilist = extract_emojis(emojistring)
- # Define polygon feature geometry
- schema = {
- 'geometry': 'Polygon',
- 'properties': {'emoji': 'str',
- 'emoji_text': 'str'},
- }
- #write Shapefile
- with fiona.open('output.shp', mode='w', encoding='UTF-8', driver='ESRI Shapefile', schema=schema,crs=from_epsg(4326)) as c:
- # Normalize Weights to 0-1000 Range
- for emoji in emojilist:
- c.write({'geometry': {'coordinates': [[(-4.663611, 51.158333),
- (-4.669168, 51.159439),
- (-4.673334, 51.161385),
- (-4.674445, 51.165276),
- (-4.67139, 51.185272),
- (-4.669445, 51.193054),
- (-4.665556, 51.195),
- (-4.65889, 51.195),
- (-4.656389, 51.192215),
- (-4.646389, 51.164444),
- (-4.646945, 51.160828),
- (-4.651668, 51.159439),
- (-4.663611, 51.158333)]],
- 'type': 'Polygon'},
- 'properties': {'emoji': emoji,
- 'emoji_text': str(unicode_name(emoji))},
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement